import { createRouter, createWebHashHistory } from "vue-router";

export const routerList = [
  {
    path: "/",
    name: "page",
    component: import("@/views/client/page"),
    redirect: "/index",
    children: [
      {
        path: "/index",
        name: "index",
        component: import("@/views/client/index")
      },
      {
        path: "/info",
        name: "info",
        component: import("@/views/client/info")
      },
      {
        path: "/pdf",
        name: "pdf",
        component: import("@/views/client/pdfview")
      }
    ]
  },
  {
    path: "/login",
    name: "login",
    component: import("@/views/login")
  },
  {
    path: "/register",
    name: "Register",
    component: import("@/views/register")
  },
  {
    path: "/home",
    name: "Home",
    component: import("@/views/admin/home/index")
  },
  {
    path: "/admin/aside",
    name: "Aside",
    redirect: "/admin/usersList",
    component: import("@/views/admin/aside/Aside"),
    children: [
      {
        path: "/admin/usersList",
        name: "UsersList",
        component: import("@/views/admin/user/UsersList")
      },
      {
        path: "/admin/plant",
        name: "PlantList",
        component: import("@/views/admin/plant/PlantList")
      },
  
      {
        path: "/admin/PlantCropRelation",
        name: "PlantCropRelation",
        component: import("@/views/admin/plant/PlantCropRelation")
      },
      {
        path: "/admin/PlantCrop",
        name: "PlantCrop",
        component: import("@/views/admin/plant/PlantCrop")
      },
      {
        path: "/admin/article",
        name: "ArticleReview",
        component:import("@/views/admin/plant/ArticleReview")
      },
      {
        path:"/admin/ImagePreview",
        name:"ImagePreview",
        component:import("@/views/admin/updataImage/ImagePreview")
      }
    ]
  }
];
const router = createRouter({
    mode: "history",
  history: createWebHashHistory(),
  routes: routerList,
  scrollBehavior(to, from, savedPosition) {
    if (to.hash) {
      return {
        selector: to.hash,
        behavior: "smooth"
      };
    } else {
      return { x: 0, y: 0 };
    }
  }
});

export default router;
